home *** CD-ROM | disk | FTP | other *** search
/ Treccani Italiana Di Scienze Lettere Ed Arti / [Enciclopedia] Treccani Italiana di scienze lettere ed arti.iso / pc / data / xxi_appendice_dvd.swf / scripts / __Packages / mx / utils / ObjectCopy.as < prev   
Text File  |  2007-11-08  |  2KB  |  60 lines

  1. class mx.utils.ObjectCopy
  2. {
  3.    function ObjectCopy()
  4.    {
  5.    }
  6.    static function copy(refObj)
  7.    {
  8.       var _loc1_ = new Function(refObj.__proto__.constructor)();
  9.       mx.utils.ObjectCopy.copyProperties(_loc1_,refObj);
  10.       return _loc1_;
  11.    }
  12.    static function copyProperties(dstObj, srcObj)
  13.    {
  14.       var _loc2_ = srcObj;
  15.       var to;
  16.       for(var i in _loc2_)
  17.       {
  18.          to = typeof _loc2_[i];
  19.          if(to != "function")
  20.          {
  21.             if(to == "object")
  22.             {
  23.                if(_loc2_[i] instanceof Array)
  24.                {
  25.                   var p = new Array();
  26.                   var _loc3_ = _loc2_[i];
  27.                   var _loc1_ = 0;
  28.                   while(_loc1_ < _loc3_.length)
  29.                   {
  30.                      p[_loc1_] = _loc3_[_loc1_];
  31.                      _loc1_ = _loc1_ + 1;
  32.                   }
  33.                   dstObj[i] = p;
  34.                }
  35.                else if(_loc2_[i] instanceof String)
  36.                {
  37.                   dstObj[i] = new String(_loc2_[i]);
  38.                }
  39.                else if(_loc2_[i] instanceof Number)
  40.                {
  41.                   dstObj[i] = new Number(_loc2_[i]);
  42.                }
  43.                else if(_loc2_[i] instanceof Boolean)
  44.                {
  45.                   dstObj[i] = new Boolean(_loc2_[i]);
  46.                }
  47.                else
  48.                {
  49.                   dstObj[i] = mx.utils.ObjectCopy.copy(_loc2_[i]);
  50.                }
  51.             }
  52.             else
  53.             {
  54.                dstObj[i] = _loc2_[i];
  55.             }
  56.          }
  57.       }
  58.    }
  59. }
  60.